//
//  TestReversiBoardLineDirection.m
//  Reversi
//
//  Created by 成瀬 龍人 on 2/6/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TestReversiBoardLineDirection.h"
#import "ReversiBoardLineDirection.h"

@implementation TestReversiBoardLineDirection
- (void)setUp{
}

- (void)tearDown{
}

- (void)testCreateDirection{
	@try{
		ReversiBoardLineDirection* dir = [[ReversiBoardLineDirection alloc] init:0:1];
		STAssertEquals(dir.x, 0, @"x = 0"); STAssertEquals(dir.y, 1, @"y = 1");
		dir = [[ReversiBoardLineDirection alloc] init:1:1];
		STAssertEquals(dir.x, 1, @"x = 1"); STAssertEquals(dir.y, 1, @"y = 1");
		dir = [[ReversiBoardLineDirection alloc] init:1:0];
		STAssertEquals(dir.x, 1, @"x = 1"); STAssertEquals(dir.y, 0, @"y = 0");
		dir = [[ReversiBoardLineDirection alloc] init:1:-1];
		STAssertEquals(dir.x, 1, @"x = 1"); STAssertEquals(dir.y, -1, @"y = -1");
		dir = [[ReversiBoardLineDirection alloc] init:0:-1];
		STAssertEquals(dir.x, 0, @"x = 0"); STAssertEquals(dir.y, -1, @"y = -1");
		dir = [[ReversiBoardLineDirection alloc] init:-1:-1];
		STAssertEquals(dir.x, -1, @"x = -1"); STAssertEquals(dir.y, -1, @"y = -1");
		dir = [[ReversiBoardLineDirection alloc] init:-1:0];
		STAssertEquals(dir.x, -1, @"x = -1"); STAssertEquals(dir.y, 0, @"y = 0");
		dir = [[ReversiBoardLineDirection alloc] init:-1:1];
		STAssertEquals(dir.x, -1, @"x = -1"); STAssertEquals(dir.y, 1, @"y = 1");
	}@catch(ReversiOutOfRangeException* e){
		STFail(@"do not throw exception");
	}
}

- (void)testErrorCase{
	STAssertThrows([[ReversiBoardLineDirection alloc] init:0:0], @"throw exception");
	STAssertThrows([[ReversiBoardLineDirection alloc] init:2:0], @"throw exception");
	STAssertThrows([[ReversiBoardLineDirection alloc] init:0:-2], @"throw exception");
}
@end
